package com.kzy.demoadmin.web.mapper;

import com.github.pagehelper.PageInfo;
import com.kzy.demoadmin.web.entity.Reserve;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ReserveMapper {
    
    /**
     * 查询所有预约记录
     * @return
     */
    List<Reserve> findAll(Reserve reserve);
    
    /**
     * 根据ID查询预约记录
     * @param id
     * @return
     */
    @Select("SELECT * FROM reserve WHERE id = #{id}")
    Reserve findById(Integer id);
    
    /**
     * 新增预约记录
     * @param reserve
     */
    void insert(Reserve reserve);
    
    /**
     * 更新预约记录
     * @param reserve
     */
    void update(Reserve reserve);
    
    /**
     * 删除预约记录
     * @param id
     * @return
     */
    @Delete("DELETE FROM reserve WHERE id = #{id}")
    int deleteById(Integer id);
    
    /**
     * 根据用户ID查询预约记录
     * @param userId
     * @return
     */
    List<Reserve> findByUserId(Integer userId);
    
    /**
     * 根据书籍ID查询预约记录
     * @param bookId
     * @return
     */
    @Select("SELECT * FROM reserve WHERE book_id = #{bookId}")
    List<Reserve> findByBookId(Integer bookId);
}
